home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 1.iso / icons / animator.zip / ANIMATOR.H < prev    next >
C/C++ Source or Header  |  1993-04-15  |  10KB  |  224 lines

  1. #include <windows.h>
  2. #include <commdlg.h>
  3. #include <shellapi.h>
  4. #include <toolhelp.h>
  5. #include <windowsx.h>
  6. #include <direct.h>
  7. #include <memory.h>
  8. #include "rc.h"
  9.  
  10. ///////////////////// MISC DEFINES   /////////////////////////
  11.  
  12. #define WNDPROC_PARAMS              HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam
  13. #define DLGPROC_PARAMS              HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam
  14. #define MAX_FILE_SIZE               128
  15. #define MAXICONS                    32
  16. #define MINTIME                     20
  17. #define MAXTIME                     20000
  18. #define WNDMENUPOS                  2
  19. #define MAXANIMATIONS               16
  20. #define FRAME_X                     280
  21. #define FRAME_Y                     320
  22. #define ICON_DY                     GetSystemMetrics (SM_CXICON)
  23. #define ICON_DX                     GetSystemMetrics (SM_CYICON)
  24. #define PADDING                     5
  25. #define ID_CLIENT                   802
  26. #define ID_STATBAR                  803
  27. #define ID_TIMER                    1     // second param of SetTimer()
  28.                                           // and KillTimer()
  29.  
  30. /////////////////////// DATA STRUCTURES ///////////////////////////
  31.  
  32.  
  33. /* There are 8 animations possible at one time.  So, we use an
  34.    array of 8 ANIMSTRUCT structures.  Each MDI child window created
  35.    has a corresponding number, which is its index into the array. */
  36.  
  37. typedef struct tagANIMSTRUCT
  38. {
  39.     HWND    hWnd;                    // mdi child window handle
  40.     HWND    hWndTarget;              // target window handle. 
  41.     HICON   hIcons[MAXICONS];        // handles to icons loaded into memory.
  42.     HICON   hPrevIcon;               // actual application icon (before anim)
  43.     short   sNumIcons;               // number of icons in array
  44.     short   sIndex;                  // current icon displayed (index)
  45.     short   sTimeInt;                // stored timer interval.
  46.     short   sCountDn;                // countdown until icon change.
  47.     char    szEXELink[MAX_FILE_SIZE]; // filename of linked executable.
  48.     char    szFileName[MAX_FILE_SIZE];// file name of script (0 if Untitled).
  49.     BOOL    bIsEXELoaded;            // if task is loaded, true.
  50.     BOOL    bIsAnimating;            // if is actually doing the deed.
  51.     BOOL    bAutoAnimate;            // automatically animate upon load.
  52. }   ANIMSTRUCT, FAR * LPANIMSTRUCT;
  53.  
  54. /////////////////// WINDOW-SPECIFIC DATA MACROS ////////////////
  55.  
  56. // These are the offsets to the window extra bytes
  57. #define WW_HWNDLIST                 0
  58. #define WW_WINDOWNUM                2
  59. #define WW_ISDIRTY                  4
  60. #define WW_ENDOFWORDS               6
  61.  
  62. // Use these functions to set window words
  63. #define SET_HWNDLIST(x,v)           SetWindowWord (x,WW_HWNDLIST,v)
  64. #define SET_WINDOWNUM(x,v)          SetWindowWord (x,WW_WINDOWNUM,v)
  65. #define SET_ISDIRTY(x,v)            SetWindowWord (x,WW_ISDIRTY,v)
  66.  
  67. #define SET_ISANIMATING(x,v)        _animStruct[x].bIsAnimating = (BOOL)(v)
  68. #define SET_EXELOADED(x,v)          _animStruct[x].bIsEXELoaded = (BOOL)(v)
  69. #define SET_AUTOANIMATE(x,v)        _animStruct[x].bAutoAnimate = (BOOL)(v)
  70. #define SET_HWNDANIM(x,v)           _animStruct[x].hWnd = (HWND)(v)
  71. #define SET_NUMICONS(x,v)           _animStruct[x].sNumIcons = (short)(v)
  72. #define SET_INDEX(x,v)              _animStruct[x].sIndex = (short)(v)
  73. #define SET_HPREVICON(x,v)          _animStruct[x].hPrevIcon = (HICON)(v)
  74. #define SET_TIMEINT(x,v)            _animStruct[x].sTimeInt = (short)(v)
  75. #define SET_COUNTDOWN(x,v)          _animStruct[x].sCountDn = (short)(v)
  76. #define SET_HWNDTARGET(x,v)         _animStruct[x].hWndTarget = (HWND)(v)
  77.  
  78.  
  79. // Use these functions to get window word data
  80. #define HWNDLIST(x)                 (HWND)GetWindowWord (x,WW_HWNDLIST)
  81. #define WINDOWNUM(x)                (short)GetWindowWord (x,WW_WINDOWNUM)
  82. #define ISDIRTY(x)                  (BOOL)GetWindowWord (x,WW_ISDIRTY)
  83.  
  84. #define HWNDANIM(x)                 (HWND)_animStruct[x].hWnd
  85. #define ISANIMATING(x)              (BOOL)_animStruct[x].bIsAnimating
  86. #define AUTOANIMATE(x)              (BOOL)_animStruct[x].bAutoAnimate
  87. #define EXELOADED(x)                (BOOL)_animStruct[x].bIsEXELoaded
  88. #define NUMICONS(x)                 (short)_animStruct[x].sNumIcons
  89. #define INDEX(x)                    (short)_animStruct[x].sIndex
  90. #define HPREVICON(x)                (HICON)_animStruct[x].hPrevIcon
  91. #define TIMEINT(x)                  (short)_animStruct[x].sTimeInt
  92. #define COUNTDOWN(x)                (short)_animStruct[x].sCountDn
  93. #define HWNDTARGET(x)               (HWND)_animStruct[x].hWndTarget
  94. #define HICONS(x)                   _animStruct[x].hIcons
  95. #define SZFILENAME(x)               (char *)_animStruct[x].szFileName
  96. #define SZEXELINK(x)                (char *)_animStruct[x].szEXELink
  97.  
  98. //////////////////////  OTHER MACROS  ///////////////////////////////
  99.  
  100. // Invalidates status bar to be redrawn, or updated.
  101. #define UPDATE_STATBAR              InvalidateRect(_hwndStatus,NULL,TRUE)
  102.  
  103. #define LoadStr(x,y)    LoadString(_hInst,(UINT)(x),(LPSTR)(y),sizeof(y))
  104.  
  105. // my own version of WINDOWSX.H for MDI controls (you may want
  106. // to add this in to your WINDOWSX.H file):
  107.  
  108. #define MDI_GetActive(x)  (HWND)(DWORD)(SendMessage((HWND)(x), \
  109.     WM_MDIGETACTIVE,(WPARAM)0,(LPARAM)0L))
  110.  
  111. #define MDI_Create(x,y)   \
  112.     (UINT)( IsWindow((HWND)(x)) ? \
  113.             SendMessage((HWND)(x), WM_MDICREATE, (WPARAM)0, \
  114.             (LPARAM)(LPMDICREATESTRUCT)(y)) : NULL)
  115.  
  116. #define MDI_Destroy(x,y) SendMessage((HWND)(x),WM_MDIDESTROY, \
  117.     (WPARAM)(y),(LPARAM)0L)
  118.  
  119. #ifdef DEBUG
  120. #define OD(x)                       OutputDebugString ((LPSTR)x)
  121. #endif
  122.  
  123. #define Color(x)                    (COLORREF)GetSysColor(x)
  124.  
  125. ///////////////////  EXTERNAL VARIABLES   //////////////////////////
  126.  
  127. extern HINSTANCE        _hInst;
  128. extern HWND             _hwndFrame, _hwndClient, _hwndStatus;
  129. extern HMENU            _hmenuMain, _hmenuMainWindow, _hmenuChild, 
  130.                         _hmenuChildWindow;
  131. extern LONG             _lPageFlags;
  132.  
  133. extern char             _szAppName[32];
  134. extern char             _szChildClass[32];
  135. extern char             _szTitleBar[32];
  136. extern char             _szStatBarClass[32];
  137. extern char             _szUntitled[32];
  138. extern char             _szExtension[5];
  139. extern char             _szTimeInt[32];
  140. extern char             _szInfo[32];
  141. extern char             _szNumIcons[32];
  142. extern char             _szLinkFile[32];
  143. extern char             _szIconSection[32];
  144. extern char             _szIcon[32];
  145. extern char             _szAutoAnimateKey[32];
  146.  
  147. extern FARPROC          _lpfnTimer;
  148. extern FARPROC          _lpfnNotify;
  149. extern FARPROC          _lpfnAbout;
  150. extern FARPROC          _lpfnBroadcast;
  151. extern FARPROC          _lpfnSettings;
  152. extern HWND             _hTargethWnd;
  153. extern HPEN             _hpnGray;
  154. extern HPEN             _hpnBlack;
  155. extern HPEN             _hpnWhite;
  156. extern int              _nTimerInterval;
  157. extern int              _nStatBarDY;
  158. extern ANIMSTRUCT       _animStruct[MAXANIMATIONS];
  159.  
  160.  
  161. extern LPSTR            _lpszIconFilter[3];       // filter for *.ICO extension
  162. extern LPSTR            _lpszScriptFilter[5];     // filter for *.ANM and *.* 
  163. extern LPSTR            _lpszEXEFilter[5];        // filter for *.EXE and *.COM
  164.  
  165.  
  166. //////////////////  PROTOTYPE DECLARATIONS  ////////////////////////
  167.  
  168. #ifdef __cplusplus
  169. extern "C" {
  170. #endif 
  171.  
  172. // MAIN.C 
  173. extern VOID WINAPI              CenterWindow (HWND);      
  174. extern BOOL WINAPI              RestorePosition (HWND,short);
  175. extern VOID WINAPI              RecordPosition (HWND);
  176. extern short WINAPI             IntFromString (LPSTR FAR *);
  177. extern HWND WINAPI              GetWindowListbox (VOID);
  178. extern short WINAPI             GetWindowNumber(VOID);
  179. extern BOOL WINAPI              DeleteCurSel (HWND);
  180. extern VOID WINAPI              DeletePreviousHandles (HWND);
  181. extern VOID WINAPI              SetupIconHandles (HWND);
  182. extern BOOL WINAPI              CheckForDoubles (HWND);
  183. extern VOID WINAPI              MESSAGE (WORD);
  184. extern UINT WINAPI              GetTextWidth (HDC,LPSTR);
  185. extern UINT WINAPI              GetTextHeight (HDC,LPSTR);
  186. extern UINT WINAPI              GetANSITextHeight (VOID);
  187. extern HWND WINAPI              GetAppTaskWindow (char *);
  188. extern BOOL _export CALLBACK    NotifyProc (WORD,DWORD);
  189.  
  190. // FRAME.C 
  191. extern LRESULT _export CALLBACK FrameProc (WNDPROC_PARAMS);
  192. extern BOOL _export CALLBACK    BroadcastProc (HWND,LONG);
  193. extern VOID WINAPI              RefreshAnimations (VOID);
  194.  
  195. // CHILD.C 
  196. extern LRESULT _export CALLBACK ChildProc (WNDPROC_PARAMS);
  197.  
  198. // STATBAR.C 
  199. extern LRESULT _export CALLBACK StatusBarProc (WNDPROC_PARAMS);
  200.  
  201. // ABOUT.C
  202. extern BOOL _export CALLBACK    About (DLGPROC_PARAMS);
  203.  
  204. // TIMER.C
  205. extern VOID _export CALLBACK    TimerCallback (HWND,UINT,UINT,DWORD);
  206. extern VOID WINAPI              InvalidateAll (HWND, HICON);
  207.  
  208. // SETTINGS.C
  209. extern BOOL _export CALLBACK    SettingsDlg (DLGPROC_PARAMS);
  210.  
  211. // SHOWTASK.C 
  212. extern HANDLE _export CALLBACK  ShowTaskDlg(DLGPROC_PARAMS);
  213. extern BOOL _export CALLBACK    EnumCallback (HWND, LONG);
  214.  
  215. // FILEIO.C 
  216. extern BOOL WINAPI              ShowCommonDialog (HWND, LPSTR * , LPSTR, LPSTR, LPSTR, BOOL);
  217. extern VOID WINAPI              SaveIconsToFile (HWND, WORD);
  218. extern BOOL WINAPI              OpenIconsInFile (char *);
  219. extern BOOL WINAPI              LinkToExecutable (LPSTR);
  220. extern BOOL WINAPI              GetPathIfNoPath (LPSTR);
  221. #ifdef __cplusplus
  222. }
  223. #endif
  224.